<?php
$v_recordtype_id = Get_text_from_array($_SESSION['recordtype'],'PK_RECORDTYPE','PK_RECORDTYPE','PK_RECORDTYPE',$v_recordtype_filter);
$v_recordtype_order =0;
if(isset($_REQUEST['hdn_max_order'])){	
	$v_recordtype_order = intval($_REQUEST['hdn_max_order'])+1;
}
$v_record_id_list = "";
if(isset($_REQUEST['hdn_record_id_list'])){
	$v_record_id_list = $_REQUEST['hdn_record_id_list'];
	$v_arrs_record_id=explode(",",$_REQUEST['hdn_record_id_list']);
}

if(isset($_REQUEST['hdn_record_number_page'])&&$_REQUEST['hdn_record_number_page']!=""){
	$v_limit_row = $_REQUEST['hdn_record_number_page'];
} 
//echo '$v_limit_row'.$v_limit_row.'<br>';

//echo $v_record_id_list;
if(_is_sqlserver()){
	$sql = "Exec ONEGATE_RecordtypeGetSingle  ";

	$sql = $sql ."'". $v_recordtype_id . "'" ;
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$arr_single_recordtype = $ado_conn->GetRow($sql);
	$v_name_of_recordtype_id=$arr_single_recordtype['C_NAME'];
	//15092008_leav_begin
	//**Ghi chu:
	//--Tuy theo loai hs ma nguoi nhan bien lai thue la khac nhau,tuc la the username trong file cac_dong_don_xin_cap_phep.xnl
	$v_userName="";
	if(in_array($v_recordtype_id,array('001','002','003','007','010','018','020','022','028','029','030','031','032','033','039','042','043','044','048','049'))){
		$v_userName='ho_ten';
	}
	if(in_array($v_recordtype_id,array('004','005','006','009','011','012','013','014','015','019','024','027','035','036','037','038','040','041','045','046','047','050'))){
		$v_userName='registor_name';
	}
	if(in_array($v_recordtype_id,array('008','025','026','034'))){
		$v_userName='user_name';
	}
	if(in_array($v_recordtype_id,array('021'))){
		$v_userName='ho_ten_than_nhan';
	}
	if(in_array($v_recordtype_id,array('016','017','023'))){
		$v_userName='ho_va_ten';
	}
	$sql_xml="SELECT dbo.f_GetValueOfXMLtag(C_RECEIVED_RECORD_XML_DATA, '".$v_userName."') as HO_TEN ";
	$sql_xml=$sql_xml."FROM T_ONEGATE_RECORD WHERE PK_RECORD=".$v_record_id_list;
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$rs = $ado_conn->GetRow($sql_xml);
	$v_receiver_name=$rs['HO_TEN'];
	//echo "testlhfsdsd =".$v_nguoi_nhan_blai;
	if($code_notify=="1010"){
		$sql =" SELECT c_name 
				FROM   t_onegate_worktype
				WHERE  pk_worktype='TN_RTB_THUE'";
		}else{
		$sql =" SELECT c_name 
				FROM   t_onegate_worktype
				WHERE  pk_worktype='TN_RTB_PHAT'";
		
		}
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$rs = $ado_conn->GetRow($sql); 
	$v_worktype_name=$rs['c_name'];
	//
	for($i=0;$i<sizeof($v_arrs_record_id);$i++){
			$v_count=sizeof($v_arrs_record_id)-1;
			$v_id_record_i=$v_arrs_record_id[$i];
			$sql = "Exec Onegate_RecordGetSingle " . $v_id_record_i;
			$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
			$arr_single_record_i = $ado_conn->GetRow($sql);
		if($i==$v_count){
			$v_c_code=$v_c_code.$arr_single_record_i['C_CODE'];
		}else{
			$v_c_code=$v_c_code.$arr_single_record_i['C_CODE']." , ";
		}
	}
	
	//15092008_leav_end
}?>